package com.yj.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ReturnT <T> {

    private int code;
    private String msg;
    private Long timestamp;
	private T data;

    public static <T> ReturnT<T> success() {
        return new ReturnT<T>(200, "success", System.currentTimeMillis(), null);
    }

    public static <T> ReturnT<T> success(String msg) {
        return new ReturnT<T>(200, msg, System.currentTimeMillis(), null);
    }

    public static <T> ReturnT<T> success(T data) {
        return new ReturnT<T>(200, "success", System.currentTimeMillis(), data);
    }

    public static <T> ReturnT<T> success(String msg, T data) {
        return new ReturnT<T>(200, msg, System.currentTimeMillis(), data);
    }



    public static <T> ReturnT<T> error(String msg) {
        return new ReturnT<T>(500, msg, System.currentTimeMillis(), null);
    }

    public static <T> ReturnT<T> error(T data) {
        return new ReturnT<T>(500, "fail", System.currentTimeMillis(), data);
    }
}
